package com.qinggeng.framework.config.mq.impl;

import com.alibaba.fastjson.JSONObject;
import com.qinggeng.common.exception.CustomException;
import com.qinggeng.framework.config.mq.dto.MessageBulletChatDTO;
import com.qinggeng.framework.config.mq.handle.MessageHandle;
import com.qinggeng.project.api.websocket.service.BulletChatHomeLoginServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class BulletChatHomeLoginHandleImpl implements MessageHandle {

    @Resource
    private BulletChatHomeLoginServiceImpl bulletChatService;
    @Override
    public void handle(String msg) {
        System.out.println("解析handle "+msg);
        try {
            MessageBulletChatDTO messageAccountDTO=JSONObject.parseObject(msg,MessageBulletChatDTO.class);
            bulletChatService.send(messageAccountDTO);
        }catch (Exception e){
            throw  new CustomException("錯誤"+e.getMessage());

        }
    }

}
